﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// anouncement.xaml 的交互逻辑
    /// </summary>
    public partial class anouncement : Page
    {
        public anouncement()
        {
            InitializeComponent();
        }

        string strCon = Properties.Resources.strCON;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DateTime dt;
            try
            {
                DataRowView row = (DataRowView)dataGrid.SelectedItem;
                dt = (DateTime)(row["发布时间"]);
                detailNotice detail = new detailNotice(dt);
                detail.Show();
                
            }
            catch
            {
                MessageBox.Show("还未选择公告");
            }
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("select noticepeo as '发布老师', time as '发布时间' from notice ", con);
            SqlDataAdapter read = new SqlDataAdapter(cmd);

            DataTable dt = new DataTable();
            read.Fill(dt);

            DataTable dat = dt;
            dataGrid.ItemsSource = dat.DefaultView;
             
            con.Close();
        }
    }
}
